import pygetwindow as gw

# 获取所有窗口
windows = gw.getAllTitles()

# 列出所有窗口标题
for i, title in enumerate(windows):
    if title:  # 过滤掉没有标题的窗口
        print(f"{i + 1}. {title}")